import request from '@/utils/request'

// 获取所有活动
export function getActivity() {
  return request({
    url: 'activity/queryAll',
    method: 'POST'
  })
}

// 获取单个活动
export function getSingleActivity(active = 'preparing') {
  return request({
    url: 'activity/queryByStatus',
    method: 'POST',
    data: {
      activityStatus: active
    }
  })
}

// 获取活动详情
export function getActivityDetail(activityId) {
  return request({
    url: 'activity/queryById',
    method: 'POST',
    data: {
      activityId
    }
  })
}

// 后台奖品查询
export function queryPrize(page, size) {
  return request({
    url: 'lotto/query',
    method: 'POST',
    data: {
      page,
      size
    }
  })
}

// 个人获得奖品
export function queryPersonPrize(userId, page, size) {
  return request({
    url: 'user/queryAward',
    method: 'POST',
    data: {
      userId,
      page,
      size
    }
  })
}

// 抽奖接口
export function luckDraw(lottoId, userId) {
  return request({
    url: 'lotto/draw2',
    method: 'POST',
    data: {
      lottoId,
      userId
    }
  })
}

export function storeGoods(page = 1, size = 100) {
  return request({
    url: 'storeGoods/query',
    method: 'POST',
    data: {
      page,
      size
    }
  })
}

// 剩余申领金额
export function receiveQualification() {
  return request({
    url: 'receiveQualification/amount',
    method: 'POST'
  })
}

//  会员可申领订单
export function receiveCard(userId) {
  return request({
    url: 'receiveQualification/orderList',
    method: 'POST',
    data: {
      userId
    }
  })
}

// 订单申领
export function applyCard(outTradeNo) {
  return request({
    url: 'receiveQualification/apply',
    method: 'POST',
    data: {
      outTradeNo
    }
  })
}

// 合同号查询店铺
export function queryStore(storeId) {
  return request({
    url: 'store/queryStore',
    method: 'POST',
    data: {
      storeId
    }
  })
}

// 上传线下订单
export function receiveQualificationOffline(
  userId,
  posNum,
  outTradeNo,
  payAmount,
  storeId,
  payTime
) {
  return request({
    url: 'receiveQualification/offline',
    method: 'POST',
    data: {
      userId,
      posNum,
      outTradeNo,
      payAmount,
      storeId,
      payTime
    }
  })
}
